package com.shanzhe.eshop.auth.service;

import com.shanzhe.eshop.auth.pojo.AuthPriorityDO;
import com.shanzhe.eshop.auth.pojo.AuthPriorityDTO;
import com.shanzhe.eshop.common.util.ResultBean;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @Author yinwei
 * @create 2021/10/2
 * @Version 1.0
 * @desc 权限管理模块service组件
 */
public interface AuthPriorityService {

    /**
     * 查询权限列表
     * @return List<AuthPriorityDO> 权限集合
     */
    ResultBean<List<AuthPriorityDTO>> listPriorityies();

    /**
     * 根据父权限id查询子权限
     * @param parentId
     * @return
     */
    ResultBean<List<AuthPriorityDTO>> listChildPriorities(Long parentId);

    /**
     * 根据id查询权限
     * @param id 权限id
     * @return 权限
     * @throws Exception
     */
    ResultBean<AuthPriorityDTO> getPriorityById(Long id) throws Exception;

    /**
     * 查询账号被授权的权限树
     * @param accountId 账号id
     * @return 权限树
     * @throws Exception
     */
    ResultBean<List<AuthPriorityDTO>> listAuthorizedByAccountId(
            Long accountId) throws Exception;

    /**
     * 判断账号是否存在对指定编号的权限的授权记录
     * @param accountId 账号id
     * @param code 权限编号
     * @return 是否存在授权记录
     * @throws Exception
     */
    ResultBean<Boolean> existAuthorizedByCode(Long accountId, String code) throws Exception;

    /**
     * 判断账号是否存在对指定url的权限的授权记录
     * @param accountId 账号id
     * @param url 权限url
     * @return 是否存在授权记录
     * @throws Exception
     */
    ResultBean<Boolean> existAuthorizedByUrl(Long accountId, String url) throws Exception;

    /**
     * 新增权限
     * @param priorityDTO 权限
     * @throws Exception
     */
    ResultBean<Boolean> savePriority(AuthPriorityDTO priorityDTO) throws Exception;

    /**
     * 更新权限
     * @param priorityDTO 权限
     * @throws Exception
     */
    ResultBean<Boolean> updatePriority(AuthPriorityDTO priorityDTO) throws Exception;

    /**
     * 删除权限
     * @param id 权限id
     * @return 处理结果
     * @throws Exception
     */
    ResultBean<Boolean> removePriority(Long id) throws Exception;
}
